Cainiao also learns ogre-the first ogre Program

Source: Internet
Author: User

Here we refer to the basic ogrewiki tutorial, which uses the Ogre wiki tutorial framework provided on the Internet. Use cmake to compile and execute.
First look at the final result:


Core code:
Void tutorialapplication: createscene (void)
{
Mscenemgr-> setambientlight (Ogre: colourvalue (1.0, 1.0, 1.0 ));
Ogre: entity * ogrehead = mscenemgr-> createentity ("head", "ogrehead. mesh ");
Ogre: scenenode * headnode = mscenemgr-> getrootscenenode ()-> createchildscenenode ("headnode ");
Headnode-> attachobject (ogrehead );
 
Headnode-> yaw (Ogre: Degree (-90 ));
 
Ogre: entity * ogrehead2 = mscenemgr-> createentity ("head2", "ogrehead. mesh ");
Ogre: scenenode * headnode2 = mscenemgr-> getrootscenenode ()-> createchildscenenode ("headnode2", ogre: vector3 (100, 0, 0 ));
Headnode2-> attachobject (ogrehead2 );
 
Headnode2-> pitch (Ogre: Degree (-90 ));
Headnode2-> Scale (1, 2, 1 );
 
Ogre: entity * ogrehead3 = mscenemgr-> createentity ("head3", "ogrehead. mesh ");
Ogre: scenenode * headnode3 = mscenemgr-> getrootscenenode ()-> createchildscenenode ("headnode3", ogre: vector3 (200, 0, 0 ));
Headnode3-> attachobject (ogrehead3 );
 
Headnode3-> Roll (Ogre: Degree (-90 ));
}

Several important concepts:
1. scenemanager: scenemanager manages all the items visible on the screen. There are multiple types of scenemanager used to render terrain, BSP, and so on.
2. entity: An entity indicates a mesh (which can contain animations), light, camera, particle, and billboard. Entity cannot be directly added to the scenario. Attach must first be added to a scenenode to manage the location and direction of the scenenode.
3. scenenode: scenenode manages the location and direction. Note that the child node is in the space of the parent node. One scenenode can manage multiple objects.

4. The entity and scenenode names in ogre must both be globally unique.


Cmakefiles.txt also requires some changes:

#/*
#-----------------------------------------------------------------------------
# Filename: cmakelists.txt
#-----------------------------------------------------------------------------
#
# This source file is part of
#__________
#/___ \__ _ ___/// \ (_) | _(_)
# ///_ '|' _/_ \/| // |
#/\ _/(_ | _/\/| <|
# \___/\__, | _ | \___ | \/ \/| _ | \_\_ |
# | ___/
# Tutorial framework
# Http://www.ogre3d.org/tikiwiki/
#-----------------------------------------------------------------------------
#*/
Cmake_minimum_required (version 2.6)
 
Project (ogreapp)
Set (cmake_module_path "/usr/local/lib/ogre/cmake/; $ {cmake_module_path }")
Set (ogre_samples_includepath "/home/TAO/workspace/ogre_src_v1-8-0/samples/common/include /")
If (cmake_build_type strequal "")
# Cmake defaults to leaving cmake_build_type empty. This screws up
# Differentiation between debug and release builds.
Set (cmake_build_type "relwithdebinfo" cache string "choose the type of build, options are: none (cmake_cxx_flags or cmake_c_flags used) debug release relwithdebinfo minsizerel." Force)
Endif ()
 
Set (cmake_debug_postfix "_ d ")
 
Set (cmake_install_prefix "$ {cmake_current_binary_dir}/Dist ")
 
Find_package (Ogre required)
 
# If (not "$ {ogre_version_name}" strequal "cthugha ")
# Message (send_error "you need ogre 1.7 cthugha to build this .")
# Endif ()
 
Find_package (OIS required)
 
If (not ois_found)
Message (send_error "failed to find Ois .")
Endif ()
 
# Find boost
If (not ogre_build_platform_iphone)
If (Win32 or apple)
Set (boost_use_static_libs true)
Else ()
# Statically linking boost to a dynamic ogre build doesn't work on Linux 64bit
Set (boost_use_static_libs $ {ogre_static })
Endif ()
If (mingw)
# This is probably a bug in cmake: the boost find module tries to look
# Boost libraries with name libboost _ *, but cmake already prefixes Library
# Search names with "lib". This is the workaround.
Set (cmake_find_library_prefixes $ {cmake_find_library_prefixes }"")
Endif ()
Set (boost_additional_versions "1.44" "1.44.0" "1.42" "1.42.0" "1.41.0" "1.41" 1.40.0 "" 1.40 "1.39.0" "1.39" 1.38.0 "" 1.38 "" 1. 37.0 "" 1.37 ")
# Components that need linking (NB does not include header-only components like bind)
Set (ogre_boost_components thread date_time)
Find_package (boost components $ {ogre_boost_components} Quiet)
If (not boost_found)
# Try again with the other type of libs
Set (boost_use_static_libs not $ {boost_use_static_libs })
Find_package (boost components $ {ogre_boost_components} Quiet)
Endif ()
Find_package (boost quiet)
 
# Set up referencing of boost
Include_directories ($ {boost_include_dir })
Add_definitions (-dboost_all_no_lib)
Set (ogre_libraries $ {ogre_libraries }$ {boost_libraries })
Endif ()
 
Set (HDRs
./Baseapplication. h
./Tutorialapplication. h
)
 
Set (SRCS
./Baseapplication. cpp
./Tutorialapplication. cpp
)
 
Include_directories ($ {ois_include_dirs}
$ {Ogre_include_dirs}
$ {Ogre_samples_includepath}
)
 
Add_executable (ogreapp Win32 $ {HDRs }$ {SRCS })
 
Set_target_properties (ogreapp properties debug_postfix _ d)
 
Target_link_libraries (ogreapp $ {ogre_libraries }$ {ois_libraries })
 
File (make_directory $ {cmake_current_binary_dir}/Dist/bin)
File (make_directory $ {cmake_current_binary_dir}/Dist/Media)

Set (executable_output_path $ {project_binary_dir}/Dist/bin)

Install (targets ogreapp
Runtime destination Bin
Ations all)
 
Install (directory $ {cmake_source_dir}/Dist/Media
Destination ./
Ations release relwithdebinfo debug
)
 
Install (files $ {cmake_source_dir}/Dist/bin/plugins. cfg
$ {Cmake_source_dir}/Dist/bin/resources. cfg
Destination Bin
Ations release relwithdebinfo debug
)


2012-7-13

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.