Changeset 1548
 Timestamp:
 Jul 1, 2012, 1:39:19 PM (8 years ago)
 Location:
 trunk/games/ToukyDemo
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/games/ToukyDemo/Character.h
r1547 r1548 217 217 { 218 218 m_body_cos[i].z += 2.0f * seconds; 219 m_body_rotation[i].z = lol::cos(m_body_cos[i].z) * 30.0f; 219 float fPI = M_PI; 220 float Tmp = (abs(fmodf(m_body_cos[i].z, fPI * 2.0f)  fPI) / fPI); 221 Tmp = Tmp * Tmp * (3  2 * Tmp); 222 Tmp = Tmp * 2.0f  1.f; 223 m_body_rotation[i].z = Tmp * 30.0f; 224 //m_body_rotation[i].z = lol::cos(m_body_cos[i].z) * 30.0f; 220 225 break; 221 226 } … … 235 240 } 236 241 } 242 243 for (int i = 0; i < EBP_MAX; ++i) 244 { 245 mat4 WorldMatrix = mat4(1.0f); 246 int CurParent = m_body_parent[i]; 247 248 if (CurParent != i) 249 WorldMatrix = m_body_matrix_world[CurParent]; 250 251 m_body_matrix_world[i] = WorldMatrix * m_body_matrix_local[i] * mat4(quat::fromeuler_xyz(m_body_rotation[i])); 252 } 253 254 m_velocity = vec3(20.f, .0f, .0f); 255 256 m_position += m_rotation.transform(m_velocity) * seconds; 237 257 } 238 258 … … 248 268 } 249 269 250 for (int i = 0; i < EBP_MAX; ++i) 251 { 252 mat4 WorldMatrix = mat4(1.0f); 253 int CurParent = m_body_parent[i]; 254 255 if (CurParent != i) 256 WorldMatrix = m_body_matrix_world[CurParent]; 257 258 m_body_matrix_world[i] = WorldMatrix * m_body_matrix_local[i] * mat4(quat::fromeuler_xyz(m_body_rotation[i])); 259 } 260 261 m_rotation *= quat::rotate(seconds * 30.0f, vec3(0, 1, 0)); 262 mat4 main_matrix = mat4::translate(m_position) * mat4(quat::fromeuler_xyz(vec3(45.0f, .0f, .0f))) * mat4(m_rotation); 270 m_rotation *= quat::rotate(seconds * 30.0f, vec3(0, 1, 0)); 271 mat4 main_matrix = mat4::translate(m_position) * mat4(m_rotation); 263 272 264 273 for (int i = 0; i < EBP_MAX; ++i) 
trunk/games/ToukyDemo/ToukyDemo.cpp
r1547 r1548 53 53 54 54 m_URO = new UserReactiveObject(); 55 m_URO>m_position = vec3(.0f, 30.0f, .0f); 55 56 Ticker::Ref(m_URO); 56 57 57 58 m_Character = new Character(); 58 m_Character>m_position = vec3(.0f, 10.0f, .0f);59 m_Character>m_position = vec3(.0f, 10.0f, 40.0f); 59 60 Ticker::Ref(m_Character); 61 m_URO>InfluenceEntityRegistration(true, m_Character); 60 62 61 63 m_ready = false; … … 85 87 ToukyDemo::~ToukyDemo() 86 88 { 89 m_URO>InfluenceEntityRegistration(false, m_Character); 90 87 91 Ticker::Unref(m_camera); 88 92 Ticker::Unref(m_URO); 
trunk/games/ToukyDemo/UserReactiveObject.h
r1526 r1548 9 9 #define __USERREACTIVEOBJECT_H__ 10 10 11 #define DEF_X 3011 #define DEF_X 12 12 12 #define DEF_Y 1 13 #define DEF_Z 3013 #define DEF_Z 12 14 14 #define DEF_SIZE 10 15 15 #define DEF_INF_BLEND 50 … … 203 203 char const *GetName() { return "<UserReactiveObject>"; } 204 204 205 virtual bool InfluenceEntityRegistration(bool IsRegistering, WorldEntity *RegEntity) 206 { 207 for (int i = 0; i < m_influencing_entities.Count(); ++i) 208 { 209 if (!m_influencing_entities[i]) 210 m_influencing_entities.Remove(i); 211 else if (m_influencing_entities[i] == RegEntity) 212 { 213 if (IsRegistering) 214 return false; 215 else 216 { 217 m_influencing_entities.Remove(i); 218 Ticker::Unref(RegEntity); 219 return true; 220 } 221 } 222 } 223 224 m_influencing_entities << RegEntity; 225 Ticker::Ref(RegEntity); 226 227 return true; 228 } 229 205 230 protected: 206 231 virtual void TickGame(float seconds) … … 208 233 WorldEntity::TickGame(seconds); 209 234 235 m_rotation *= quat::rotate(seconds * 10.0f, vec3(0, 1, 0)); 236 LocalToWorld = mat4::translate(m_position) * mat4(m_rotation); 237 210 238 m_influence_point_list.Empty(); 211 239 … … 218 246 debug_point_angle = M_PI * 2.0f; 219 247 248 for (int i = 0; i < m_influencing_entities.Count(); ++i) 249 { 250 if (m_influencing_entities[i]) 251 { 252 mat4 LocalPos = inverse(LocalToWorld) * mat4::translate(m_influencing_entities[i]>m_position); 253 m_influence_point_list << influencing_point_infos(BLD_SPHERE, LocalPos.v3.xyz, 1.0f); 254 } 255 } 256 220 257 //m_influence_point_list << influencing_point_infos(BLD_SPHERE, vec3(lol::cos(debug_point_angle) * DEF_X, 0, lol::sin(debug_point_angle) * DEF_Z) * DEF_SIZE * 0.3f, 1.0f); 221 m_influence_point_list << influencing_point_infos(BLD_SQUARE, vec3(lol::cos(debug_point_angle) * DEF_X, 0, lol::sin(debug_point_angle) * DEF_Z) * DEF_SIZE * 0.3f, 1.0f);258 //m_influence_point_list << influencing_point_infos(BLD_SQUARE, vec3(lol::cos(debug_point_angle) * DEF_X, 0, lol::sin(debug_point_angle) * DEF_Z) * DEF_SIZE * 0.3f, 1.0f); 222 259 223 260 ComputeInfluenceValues(); … … 371 408 } 372 409 373 m_rotation *= quat::rotate(seconds * 10.0f, vec3(0, 1, 0));374 mat4 main_matrix = mat4::translate(m_position) * mat4(m_rotation);375 410 for (int i=0; i < m_point_list.Count(); i++) 376 411 { 377 mat4 model = main_matrix*412 mat4 model = LocalToWorld * 378 413 mat4::translate(m_point_list[i].m_final_pos) * 379 414 mat4(quat::fromeuler_yxz(m_point_list[i].m_final_rot)) * … … 385 420 private: 386 421 //mesh used to render UserReactiveObject 387 EasyMesh 422 EasyMesh m_ref_mesh; 388 423 //List of Pos/Rot/Etc... currently applied to the UserReactiveObject's meshes. 389 Array<transient_infos> 424 Array<transient_infos> m_point_list; 390 425 //List of influence steps 391 Array<influence_infos> 426 Array<influence_infos> m_influence_list; 392 427 //List of currently influencing points 393 Array<influencing_point_infos> m_influence_point_list; 394 395 float wave_angle; 396 float debug_point_angle; 397 bool m_ready; 428 Array<influencing_point_infos> m_influence_point_list; 429 //List of currently influencing entities (converted in m_influence_point_list at each frame). 430 Array<WorldEntity*> m_influencing_entities; 431 432 float wave_angle; 433 float debug_point_angle; 434 mat4 LocalToWorld; 435 bool m_ready; 398 436 }; 399 437
Note: See TracChangeset
for help on using the changeset viewer.